import React, { useRef } from "react";
import PubSub from "pubsub-js";

export default function HerosSearch() {
	let con = useRef();
	//创建搜索函数
	let serach = () => {
		let value = con.current.value;
		// console.log(value);

		//发布数据    publish("发布名称",发布的数据)
		PubSub.publish("keyword", value);
	};

	return (
		<div style={{ float: "right" }}>
			<input ref={con} type="search" placeholder="请输入英雄~~~" />
			<button onClick={serach}>搜索</button>
		</div>
	);
}
